// mycomponent/grabbing-order-list/grabbing-order-list.js
const app = getApp()
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    list: {
      type: Array,
      value: []
    },
    listType: {
      type: String,
      value: ''
    },
    tabIndex: {
      type: Number,
      value: 0
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * 跳转到订单详情
     * @param {Object} e 
     */
    goToDetail: function(e) {
      const { item } = e.currentTarget.dataset
      const now = new Date
      const start = new Date(item.startTime.replace(/-/g, '/'))
      const timeDifference = start - now
      const h24 = 24 * 60 * 60 * 1000
      if (timeDifference < h24) {
        app.tips('抢单已结束')
        return
      }
      let url = ''
      if (item.type == 1) {
        url = '/packageFT/guide/grabbing-order-detail/grabbing-order-detail'
      } else if (item.type == 2) {
        url = '/packageFT/hotel/grabbing-order-detail/grabbing-order-detail'
      }
      if (url) {
        wx.navigateTo({
          url
        })
      } else {
        app.tips('地址有误！')
      }
    }
  }
})